package com.niit.yhserver.mapper;

import com.niit.yhpojo.entity.Admin;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Service;

import java.util.List;

@Mapper
public interface AdminMapper {

    /**
     * 根据用户名查找管理员
     * @param username 用户名
     * @return 管理员对象
     */
    @Select("SELECT * FROM admin WHERE username = #{username} and password = #{password}")
    Admin login(@Param("username") String username,@Param("password") String password);

    //显示全部
    @Select("SELECT * FROM admin")
    List<Admin> getAllAdmin();

    //按照id进行查询
    @Select("SELECT * FROM admin WHERE id = #{id}")
    Admin findAdminOneById(Integer id);

    //新增管理员
    @Insert("INSERT into admin (username, password, name, create_time, update_time) VALUES (#{username},#{password},#{name},#{createTime},#{updateTime})")
    void addAdmin(Admin admin);

    //更新管理员
    void updateAdmin(Admin admin);

    //删除管理员
    @Delete("DELETE from admin WHERE id = #{id}")
    void deleteAdminById(Integer id);

}
